import { MockMethod } from 'vite-plugin-mock'

export default [
  // 测试GET请求
  {
    url: '/api/test',
    method: 'get',
    response: (req) => {
      console.log('Mock GET request:', req)
      return {
        code: 200,
        data: {
          list: [
            {
              id: 1,
              name: '张三',
              email: 'zhangsan@example.com',
              address: '北京市'
            },
            {
              id: 2,
              name: '李四',
              email: 'lisi@example.com',
              address: '上海市'
            }
          ]
        },
        message: 'success'
      }
    }
  },
  // 测试POST请求
  {
    url: '/api/login',
    method: 'post',
    response: ({ body }) => {
      console.log('Mock POST request:', body)
      const { username, password } = body
      if (username === 'admin' && password === '123456') {
        return {
          code: 200,
          data: {
            token: 'mock-token-123456',
            userInfo: {
              id: 1,
              username: 'admin',
              nickname: '管理员',
              avatar: 'https://example.com/avatar.jpg'
            }
          },
          message: '登录成功'
        }
      }
      return {
        code: 401,
        data: null,
        message: '用户名或密码错误'
      }
    }
  }
] as MockMethod[] 